<!--#include file="common/header.html"-->
<body>
    <div class="container-fluid larry-wrapper">
        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-12">
                <!--头部搜索-->
                <section class="panel panel-padding">
                    <form class="layui-form" action="/education/admin/top">
                        <input name="_query.type" id="marqueeType" value="2" type="hidden">
                        <div class="layui-form">
                            <div class="layui-inline">
                                <div class="layui-input-inline">
                                    <input class="layui-input" name="_query.keyword" placeholder="关键字">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <button lay-submit class="layui-btn" lay-filter="search">查找</button>
                            </div>
                        </div>
                    </form>
                </section>

                <!--列表-->
                <section class="panel panel-padding">

                    <div class="group-button">
                        <button class="layui-btn layui-btn-small modal-catch"
                                data-params='{"content":".add-subcat", "title":"添加","type":"1", "full":"true", "maxmin":"true"}'>
                            <i class="iconfont">&#xe649;</i> 添加
                        </button>
                        <button class="layui-btn layui-btn-small layui-btn-danger ajax-all" data-name="checkbox" data-params='{"url": "/education/admin/top/delete"}'>
                            <i class="iconfont">&#xe626;</i> 删除
                        </button>
                    </div>
                    <div id="list" class="layui-form"></div>

                    <div class="text-right" id="page"></div>
                </section>
            </div>
        </div>
    </div>

    <div class="add-subcat">
        <form class="layui-form layui-form-pane" action="/education/admin/top/save" id="form1">
            <!--<input type="hidden" name="id">-->
            <input type="hidden" name="type" id="type">
            <input type="hidden" name="module_id" id="moduleId">

            <div class="layui-form-item">
                <label class="layui-form-label">专场</label>
                <div class="layui-input-inline">
                    <input type="hidden" name="module_id" >
                    <input type="text" name="parentname" class="layui-input" readonly>
                </div>
                <a class="layui-btn" onclick="beforeChoice();">
                    <i class="iconfont">&#xe649;</i> 选择
                </a>
            </div>



            <div class="layui-form-item">
                <label class="layui-form-label">排序</label>
                <div class="layui-input-inline">
                    <input type="number" name="ord" required jq-verify="required" jq-error="排序必须为数字" value="0"
                           class="layui-input ">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" jq-submit jq-filter="submit" before-fun="beforeSubmit();">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>

</body>
<script id="list-tpl" type="text/html"
        data-params='{"url":"/education/admin/top?_query.type=1","dataName":"topData","pageid":"#page", "method":"post"}'>
    <table id="example" class="layui-table lay-even" data-name="topData" data-tplid="list-tpl">
        <thead>
        <tr>
            <th width="30"><input type="checkbox" id="checkall" data-name="checkbox" lay-filter="check"
                                  lay-skin="primary"></th>
            <th width="350">专场名称</th>
            <th>封面图</th>
            <th>客户端图片状态</th>
            <th>排序</th>
            <th width="170">创建时间</th>
            <!--<th width="200">操作</th>-->
        </tr>
        </thead>
        <tbody>
        {{# layui.each(d.list, function(index, item){ }}
        <tr>
            <td><input type="checkbox" name="checkbox" value="{{ item.id}}" lay-skin="primary"></td>
            <td>
                {{ item.title }}
            </td>
            <td>
                <img src="/education{{ item.image }}" alt="..." class="img-thumbnail" style="height: 120px;">
            </td>
            <td>
                <input type="checkbox" name="switch" lay-skin="switch" lay-text="显示|隐藏" {{#if (item.is_app_show ){ }}checked="checked" {{# } }} lay-filter="ajax"
                       data-params='{"url":"/education/admin/top/set","data":"id={{ item.id}}&name=paco"}'>
            </td>

            <td class="edit" data-list='{"key":"id={{ item.id}}","filed":"ord","render":"true"}'
                data-params='{"url":"/education/admin/top/update/{{ item.id}}"}'>
                {{ item.ord||''}}
            </td>
            <td>{{# if(item.create_time == null){ }} {{#  } else { }} {{ item.create_time}}  {{#  } }}</td>
        </tr>
        {{# }); }}
        </tbody>
    </table>
</script>
<script src="../js/layui/layui.js"></script>
<script type="text/javascript" src="../js/lib/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="../js/lib/rest.js"></script>

<!--#include file="common/version.html"-->
<script>
    layui.define(['jquery', 'dtable', 'jqdate', 'jqform', 'upload'], function(exports) {
        var $ = layui.jquery,
            list = layui.dtable,
            form = layui.jqform,
            oneList = new list();
        form.set({
            "change": true,
            "form": "#form1"
        }).init(oneList);

        var url = "/education/admin/top?_query.type=" + $('#marqueeType').val();

        $('#list-tpl').attr('data-params',
            '{"url":"'+url+'","dataName":"top2Data","pageid":"#page", "method":"post", "data":"orderColunm=ord,create_time&orderMode=desc"}');
        oneList.init('list-tpl');

    });

    /*
     选择商品弹出框
      */
    function choiceDept(item){
        var $ = layui.jquery;
        $('input[name="module_id"]').val(item.id);
        $('input[name="parentname"]').val(item.name);
    }

    function beforeChoice(){
        var index = layer.open({
            type: 2,
            content: "menu-tree.html?m=group", "title": "选择专场", "area": ['500px','400px'], "maxmin":"true"
        });
    }

    function beforeSubmit(){
        $('#type').val(2);
    }
</script>
</html>